
/*
'===============================================================================
'  Generated From - DAAB_DAL_NET2_Inherited.vbgen
'  It is based on the DAAB from the November 2005 Enterprise Library
'  
'  This object inherits properties, members and methods from the base class _Address_DAL.
' 
'  Use this class file for writing custom DAL methods. 
'  
'  Version: 1.0
'  Date:	30/01/06
'  Summary: Defaul constructor.
'===============================================================================
*/
using System;
using System.Data;
using System.Data.Common;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;

namespace PlacementManager.DAL
{
    public class Address_DAL : _Address_DAL
    {
        //Constructor
        public Address_DAL()
        {

        }

        /// <summary>
        /// Purpose: Select Primary method. This method will Select one existing row from the database, based on the Primary Key.
        /// </summary>
        /// <returns></returns>
        public DataSet SelectPrimaryAddressForVenue(int venueId)
        {
            // Create the Database object, using the default database service. The
            // default database service is determined through configuration.
            Database db = DatabaseFactory.CreateDatabase("PlacementManager");

            string sqlCommand = "pr_Address_DAL_SelectPrimaryAddressForVenue";
            DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);

            db.AddInParameter(dbCommand, "VenueId", DbType.Int32, venueId);

            db.AddOutParameter(dbCommand, "ErrorCode", DbType.Int32, 4);

            DataSet dsToReturn = null;
            dsToReturn = db.ExecuteDataSet(dbCommand);
            return dsToReturn;
        }

        /// <summary>
        /// Purpose: Select Primary method. This method will Select one existing row from the database, based on the Primary Key.
        /// </summary>
        /// <returns></returns>
        public DataSet SelectPrimaryAddressForContact(int contactId)
        {
            // Create the Database object, using the default database service. The
            // default database service is determined through configuration.
            Database db = DatabaseFactory.CreateDatabase("PlacementManager");

            string sqlCommand = "pr_Address_DAL_SelectPrimaryAddressForContact";
            DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);

            db.AddInParameter(dbCommand, "ContactId", DbType.Int32, contactId);

            db.AddOutParameter(dbCommand, "ErrorCode", DbType.Int32, 4);

            DataSet dsToReturn = null;
            dsToReturn = db.ExecuteDataSet(dbCommand);
            return dsToReturn;
        }

        /// <summary>
        /// Purpose: SelectAll method. This method will Select all rows from the table.
        /// </summary>
        /// <returns></returns>
        public DataSet SelectAllForVenue(int venueId)
        {
            // Create the Database object, using the default database service. The
            // default database service is determined through configuration.
            Database db = DatabaseFactory.CreateDatabase("PlacementManager");

            string sqlCommand = "pr_Address_DAL_SelectAllForVenue";
            DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);

            // Retrieve products from the specified category.
            db.AddInParameter(dbCommand, "VenueId", DbType.Int32, venueId);
            db.AddOutParameter(dbCommand, "ErrorCode", DbType.Int32, 4);

            DataSet dsToReturn = null;
            dsToReturn = db.ExecuteDataSet(dbCommand);
            return dsToReturn;
        }

        /// <summary>
        /// Purpose: Select method. This method will Select one existing row from the database, based on the Primary Key.
        /// </summary>
        /// <returns></returns>
        public DataSet SelectOneWAddress1(string address1)
        {
            // Create the Database object, using the default database service. The
            // default database service is determined through configuration.
            Database db = DatabaseFactory.CreateDatabase("PlacementManager");

            string sqlCommand = "pr_Address_DAL_SelectOneWAddress1";
            DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);

            db.AddInParameter(dbCommand, "Address1", DbType.AnsiString, address1);
            db.AddInParameter(dbCommand, "ErrorCode", DbType.Int32, null);

            DataSet dsToReturn = null;
            dsToReturn = db.ExecuteDataSet(dbCommand);
            return dsToReturn;
        }

        /// <summary>
        /// Sets the primary address for a venue
        /// </summary>
        /// <param name="addressId"></param>
        public void SetVenuePrimaryAddress(int addressId)
        {
            // Create the Database object, using the default database service. The
            // default database service is determined through configuration.
            Database db = DatabaseFactory.CreateDatabase("PlacementManager");

            string sqlCommand = "pr_LinkVenueAddress_DAL_SetPrimaryAddress";
            DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);

            db.AddInParameter(dbCommand, "AddressId", DbType.Int32, addressId);
            db.AddOutParameter(dbCommand, "ErrorCode", DbType.Int32, 4);
            db.ExecuteNonQuery(dbCommand);
        }
        /// <summary>
        /// Sets the primary address for a contact
        /// </summary>
        /// <param name="addressId"></param>
        public void SetContactPrimaryAddress(int addressId)
        {
            // Create the Database object, using the default database service. The
            // default database service is determined through configuration.
            Database db = DatabaseFactory.CreateDatabase("PlacementManager");

            string sqlCommand = "pr_LinkContactAddress_DAL_SetPrimaryAddress";
            DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);

            db.AddInParameter(dbCommand, "AddressId", DbType.Int32, addressId);
            db.AddOutParameter(dbCommand, "ErrorCode", DbType.Int32, 4);
            db.ExecuteNonQuery(dbCommand);
        }
        /// <summary>
        /// Purpose: Select Primary method. This method will Select one existing row from the database, based on the Primary Key.
        /// </summary>
        /// <returns></returns>
        public DataSet SelectPrimaryAddressForUser(int userID)
        {
            // Create the Database object, using the default database service. The
            // default database service is determined through configuration.
            Database db = DatabaseFactory.CreateDatabase("PlacementManager");

            string sqlCommand = "pr_Address_DAL_SelectPrimaryAddressForUser";
            DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);

            db.AddInParameter(dbCommand, "UserId", DbType.Int32, userID);
            db.AddOutParameter(dbCommand, "ErrorCode", DbType.Int32, 4);

            DataSet dsToReturn = null;
            dsToReturn = db.ExecuteDataSet(dbCommand);
            return dsToReturn;
        }

        /// <summary>
        /// Purpose: Select method. This method will Select one existing row from the database, based on the Primary Key.
        /// </summary>
        /// <returns></returns>
        public DataSet SelectOneWContactId(int contactId)
        {
            // Create the Database object, using the default database service. The
            // default database service is determined through configuration.
            Database db = DatabaseFactory.CreateDatabase("PlacementManager");

            string sqlCommand = "pr_Address_DAL_SelectOneWContactId";
            DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);

            db.AddInParameter(dbCommand, "ContactId", DbType.AnsiString, contactId);
            db.AddOutParameter(dbCommand, "ErrorCode", DbType.Int32, 4);

            DataSet dsToReturn = null;
            dsToReturn = db.ExecuteDataSet(dbCommand);
            return dsToReturn;
        }

        /// <summary>
        /// Purpose: SelectAll method. This method will Select all rows from the table.
        /// </summary>
        /// <returns></returns>
        public DataSet SelectAllForContact(int contactId)
        {
            // Create the Database object, using the default database service. The
            // default database service is determined through configuration.
            Database db = DatabaseFactory.CreateDatabase("PlacementManager");

            string sqlCommand = "pr_Address_DAL_SelectAllForContact";
            DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);

            // Retrieve products from the specified category.
            db.AddInParameter(dbCommand, "ContactId", DbType.Int32, contactId);
            db.AddOutParameter(dbCommand, "ErrorCode", DbType.Int32, 4);

            DataSet dsToReturn = null;
            dsToReturn = db.ExecuteDataSet(dbCommand);
            return dsToReturn;
        }

        /// <summary>
        /// Purpose: SelectAll method. This method will Select all rows from the table.
        /// </summary>
        /// <returns></returns>
        public DataSet SelectAllForUser(int userId)
        {
            // Create the Database object, using the default database service. The
            // default database service is determined through configuration.
            Database db = DatabaseFactory.CreateDatabase("PlacementManager");

            string sqlCommand = "pr_Address_DAL_SelectAllForUser";
            DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);

            // Retrieve products from the specified category.
            db.AddInParameter(dbCommand, "UserId", DbType.Int32, userId);
            db.AddOutParameter(dbCommand, "ErrorCode", DbType.Int32, 4);

            DataSet dsToReturn = null;
            dsToReturn = db.ExecuteDataSet(dbCommand);
            return dsToReturn;
        }
	}
}
